
<?php  	
// 基本的json传输
header('Content-type: text/html;charset=utf-8');
header('Content-Type:application/json');


function decodeUnicode($str){
	return preg_replace_callback('/\\\\u([0-9a-f]{4})/i',
	create_function(
		'$matches',
		'return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");'
	),
	$str);
}
$con = mysql_connect("localhost", "root", "root");
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);

mysql_query("set names 'utf8'");
//更新指定id的star
$sqlstring="UPDATE `table01` SET `star` = ".$_POST["para_star"]." WHERE id= ".$_POST["para_id"];
$result = mysql_query($sqlstring);
//更新chinese
$sqlstring2="UPDATE `table01` SET `chinese` = '".decodeUnicode( $_POST["para_chinese"])."' WHERE id= ".$_POST["para_id"];
$result2 = mysql_query($sqlstring2);

//更新lastnum
$result = mysql_query("SELECT max(`lastnum`) as max FROM `table01`");
$row = mysql_fetch_array($result);
$lastnum= $row[0]+1;
$sqlstring="UPDATE `table01` SET `lastnum` = ".$lastnum." WHERE id= ".$_POST["para_id"];
$result = mysql_query($sqlstring);

//更新lastdate
$sqlstring="UPDATE `table01` SET `lastdate` = curdate() WHERE id= ".$_POST["para_id"];
$result = mysql_query($sqlstring);



mysql_close($con);	
	//$raw_success =array($_POST["para_id"],$_POST["para_star"],$_POST["para_chinese"],decodeUnicode( $_POST["para_chinese"]),$sqlstring,$sqlstring2);	
	$raw_success='';
	$res_success = json_encode($raw_success);	
	echo $res_success;
	
?> 
